package com.sugar.subscribe.course.module.business.controller.admin.order.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

import static com.sugar.subscribe.course.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static com.sugar.subscribe.course.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "管理后台 - 订单 Response VO")
@Data
public class OrderDetailRespVO {

    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1775")
    private Long id;

    @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11074")
    private Long userId;

    @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
    private String orderNo;

    @Schema(description = "教练ID", example = "18361")
    private Long coachId;

    @Schema(description = "教练姓名", example = "18361")
    private String coachName;

    @Schema(description = "教练手机号", example = "18361")
    private String coachMobile;

    @Schema(description = "上课日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalDateSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate attendClassDate;

    @Schema(description = "上课地点ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "22762")
    private Long venueId;

    @Schema(description = "上课地点名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    private String venueName;

    @Schema(description = "服务二级分类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15019")
    private Long[] serviceIds;

    @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = "HH:mm")
    private LocalTime startTime;

    @Schema(description = "教学人数（字典：business_coach_service_people_count）", requiredMode = Schema.RequiredMode.REQUIRED, example = "19")
    private String peopleCount;

    @Schema(description = "教学时间（字典：business_coach_service_time）", requiredMode = Schema.RequiredMode.REQUIRED)
    private String serviceTime;

    @Schema(description = "雪板类型（字典：business_snowboard_type）", example = "1")
    private String snowboardType;

    @Schema(description = "滑行水平（字典：business_gliding_level）")
    private String businessGlidingLevel;

    @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    private String nickname;

    @Schema(description = "联络手机号", requiredMode = Schema.RequiredMode.REQUIRED)
    private String mobile;

    @Schema(description = "备注", example = "随便")
    private String remark;

    /**
     * 是否修改过上课时间：[0否；1是]
     */
    private Boolean updatedAttendClassDate;

    @Schema(description = "实付金额（单位分）")
    private Integer paymentAmount;

    @Schema(description = "预估收益（单位分）根据实付金额计算", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer profitAmount;

    @Schema(description = "收益是否到账：[0未到账；1已到账]")
    private Integer profitArrivalStatus;

    @Schema(description = "收益预计到账时间")
    private LocalDateTime predictProfitArrivalTime;

    @Schema(description = "收益实际到账时间")
    private LocalDateTime profitArrivalTime;
    /**
     * 是否有扣教练违约金：[0否；1是]
     */
    private Boolean isDeductLiquidatedDamages;
    /**
     * 教练违约金（单位分）
     */
    private Integer liquidatedDamages;

    @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime orderTime;

    @Schema(description = "支付状态（0待支付；1已支付）", example = "1")
    private Boolean paymentStatus;

    @Schema(description = "支付时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime paymentTime;

    @Schema(description = "接单时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime receivedTime;

    @Schema(description = "取消时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime cancelTime;

    @Schema(description = "取消类型（0未取消；1系统自动取消；2用户取消；3教练取消）", example = "2")
    private Integer cancelType;

    @Schema(description = "上课时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime attendClassTime;

    @Schema(description = "上课图片")
    private List<String> attendClassImages;

    @Schema(description = "订单完成时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime doneTime;

    @Schema(description = "订单类型（0一键约课；1直选教练约课）类型为 1 的，若教练不接单，则自动取消订单，并退款", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Boolean orderType;

    @Schema(description = "订单状态（0待接单；1已取消；2待上课；3待确认；4已完成）", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer status;

    @Schema(description = "退款状态（0未退款；1退款中；2已到账）", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer refundStatus;

    @Schema(description = "退款单号")
    private String refundOrderNo;

    @Schema(description = "退款金额（单位分）")
    private Integer refundAmount;

    @Schema(description = "退款时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime refundTime;

    @Schema(description = "退款到账时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime refundArrivalTime;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createTime;
}
